package main

import "fmt"

func twosum(nums []int, target int) []int {
	if len(nums) == 0 || nums == nil {
		return nil
	}

	left := 0
	right := len(nums) - 1
	for left < right {
		if nums[left]+nums[right] > target {
			right--
		} else if nums[left]+nums[right] < target {
			left++
		} else {
			return []int{left + 1, right + 1}
		}
	}

	return nil
}

func main() {
	nums := []int{2, 7, 11, 15}
	target := 9

	result := twosum(nums, target)
	fmt.Println(result)
}
